package com.aliyun.oss.controller;

import com.aliyun.oss.pojo.Vo.*;
import com.aliyun.oss.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;
    @RequestMapping("/turnoverStatistics")
    public ResultVO turnoverStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        TurnoverReportVO turnoverReportVO = reportService.getTurnoverStatistics(begin,end);
        return ResultVO.success(turnoverReportVO);
    }
    @GetMapping("/userStatistics")
    public ResultVO userStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                                   @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        UserReportVO userReportVO = reportService.getUserStatistics(begin,end);
        return ResultVO.success(userReportVO);
    }
//    统计订单数据
    @GetMapping("/ordersStatistics")
    public ResultVO ordersStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate begin,
                                     @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end
                                     ){
        OrderReportVO orderReportVO = reportService.getOrdersStatistics(begin,end);
        return ResultVO.success(orderReportVO);
    }
//    统计菜品销量前10
    @GetMapping("/top10")
    public ResultVO top10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        SelesTop10ReportVO selesTop10ReportVO= reportService.getSelesTop10(begin,end);
        return ResultVO.success(selesTop10ReportVO);
    }
}
